﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user02.aspx.cs" Inherits="utd_hrrs.user02" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<script runat="server">

    protected void callPayment(object sender, GridViewRowEventArgs e)
    {

    }
    
    protected void Logout_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    
    }
    protected void AddindReservation(object sender, EventArgs e)
    {
        /*
        myLabel.Visible = true;
        myLabel.Text = "Reservation Added";
        lb_equiptype.Text = DropDownList1.Text;
        lb_sdate.Text = Calendar1.SelectedDate.ToString();
        lb_edate.Text = Calendar2.SelectedDate.ToString();
        lb_shr.Text = ddList_sh.SelectedValue;
        lb_smin.Text = ddList_sm.SelectedValue;
        lb_ehr.Text = ddList_eh.SelectedValue;
        lb_emin.Text = ddList_em.SelectedValue;

        //InsertTentativeReservation;
        */ 
  
    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {

        e.Row.Font.Italic = true;
        //e.Row.FindControl("pmtButton").Visible = false;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            System.Data.DataRowView dr = (System.Data.DataRowView)e.Row.DataItem;
            //myLabel.Visible = true;
            //myLabel.Text = (String)dr.Row.ItemArray[7];
            //dr.Row.ItemArray.;
            //if ((String)dr.Row.ItemArray[7] == "n")
            //{
            //    HyperLink HyperLink1 = e.Row.FindControl("HyperLink1") as HyperLink;
            //    HyperLink1.Visible = false;

            //}

            if (dr != null)
            {
                if (dr.Row.ItemArray[7].ToString() == "y" && dr.Row.ItemArray[8].ToString() == "1")
                {
                    (e.Row.Cells[9].Controls[0]).Visible = true;
                }
                else
                {
                    (e.Row.Cells[9].Controls[0]).Visible = false;
                }
            }
            		

            //Convert.ToBoolean(dr["CONFIRMED"].ToString());
            //if (Convert.ToBoolean(dr["PAYMENT"].ToString()))
            //{
            //    LinkButton LinkButton = (LinkButton)e.Row.Findcontrol("pmtButton");
            //    LinkButton.Visible = false;
            //}

        }

        
    
       // e.Row.Cells[0]..Controls[0].Visible = false;

        //e.Row.FindControl("Pay").Visible = false;
        //e.Row.Cells[3].Visible = false;
        //e.Row.[3].Visible = false;


        //e.Row.Cells[0].Visible = false;        
        
        //GridView1.DataKeyNames;
        //e.Row.DataItem
        
        //if(e.Row.Cells[6].ToString().Equals("n")) {
        //    e.Row.Cells[8].Visible = false;
        //}

        //e.Row.Cells[0].Visible = false;
        //e.Row.Cells[0].Visible = false;

        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    int statusReserv = (int)DataBinder.Eval(e.Row.DataItem, "1");

        //    if (statusReserv == 'n')
        //    {
        //        e.Row.BackColor = System.Drawing.Color.LightPink;
        //        e.Row.ForeColor = System.Drawing.Color.Maroon;
        //    }
        //    else if (statusReserv == 'y')
        //    {
        //        e.Row.BackColor = System.Drawing.Color.LightCyan;
        //        e.Row.ForeColor = System.Drawing.Color.DarkBlue;
        //    }
        //    else
        //    {
        //        e.Row.BackColor = System.Drawing.Color.LightGray;
        //        e.Row.ForeColor = System.Drawing.Color.Red;
        //    }
        //}

    }   



    
    
    

</script>
<script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
    <script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
    konami = new Konami()
    konami.load("javascript:var%20s%20=%20document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='http://erkie.github.com/asteroids.min.js';void(0);");
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 124px;
            text-align: right;
        }
        .style2
        {
            width: 143px;
        }
        .style3
        {
            width: 81px;
        }
        .controlcolumn
        {
            width: 768px;
        }
        .style4
        {
            width: 66px;
            text-align: right;
        }
        .style5
        {
            width: 79px;
            text-align: left;
        }
        .style6
        {
            width: 143px;
            text-align: right;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:UTD_HRRSConnectionString %>" 
            DeleteCommand="DELETE FROM [RESERVATION] WHERE [RESERV_ID]=@RESERV_ID"
            UpdateCommand="INSERT INTO [PAYMENT] (AMOUNT, DATE) VALUES ('15', '04/26/2011'); UPDATE [RESERVATION] SET PMT_ID = (SELECT MAX(PMT_ID) FROM [PAYMENT]) WHERE RESERV_ID = @RESERV_ID"
            onselecting="SqlDataSource2_Selecting"
            
            
            SelectCommand="SELECT r.RESERV_ID, r.INV_ID, convert(varchar, r.START_DATE, 110) as START_DATE, convert(varchar, r.END_DATE, 110) as END_DATE, r.START_TIME, r.END_TIME, i.EQUIP_TYPE, s.RESERV_STATUS as RESERV_STATUS, r.PMT_ID FROM RESERVATION r, INVENTORY i, STATUS s WHERE USER_ID=@usr2 AND GETDATE() &lt; START_DATE AND r.INV_ID=i.INV_ID  AND s.STATUS_ID=r.STATUS_ID ORDER BY r.START_DATE">
           <DeleteParameters>
               <asp:Parameter Name="RESERV_ID" />
           </DeleteParameters>
           <SelectParameters>
               <asp:Parameter Name="usr2" />
           </SelectParameters>
        </asp:SqlDataSource>
        <br />

    <table class="controlcolumn" border="0" cellpadding="0" cellspacing="0" 
            frame="border">
        <tr>
            <td class="style5">
        Welcome, <asp:Label ID="userID" runat="server" Text="Label"></asp:Label>
&nbsp;&nbsp;</td>
            <td><a href="UserInfo.aspx">User Options</a></td>
            <td class="style6">
                &nbsp;</td>
            <td class="style4">
                    <asp:Button ID="LogoutButton" onCLick=Logout_Click runat="server" Text="Logout" 
                        style="text-align: right" />
            </td>
        </tr>
        </table>

        <h2 style="width: 255px">Current Reservations</h2>
         <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                AllowSorting="True" DataSourceID="SqlDataSource2" 
                AutoGenerateColumns="False" DataKeyNames="RESERV_ID" BackColor="White" 
            BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
            ForeColor="Black" GridLines="Vertical" OnRowCreated="GridView1_RowCreated">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:BoundField DataField="RESERV_ID" HeaderText="RESERV_ID" ReadOnly="True" 
                        SortExpression="RESERV_ID" Visible="False" />
                    <asp:BoundField DataField="EQUIP_TYPE" HeaderText="EQUIP_TYPE" 
                        SortExpression="EQUIP_TYPE" />
                    <asp:BoundField DataField="START_DATE" HeaderText="START_DATE" 
                        SortExpression="START_DATE" />
                    <asp:BoundField DataField="END_DATE" HeaderText="END_DATE" 
                        SortExpression="END_DATE" />
                    <asp:BoundField DataField="START_TIME" HeaderText="START_TIME" 
                        SortExpression="START_TIME" />
                    <asp:BoundField DataField="END_TIME" HeaderText="END_TIME" 
                        SortExpression="END_TIME" />
                    <asp:BoundField DataField="RESERV_STATUS" HeaderText="CONFIRMED" 
                        SortExpression="RESERV_STATUS" />
                    <asp:BoundField DataField="PMT_ID" Visible="false" />
                    <asp:ButtonField ButtonType="Button" CommandName="Delete" 
                        HeaderText="REMOVE" ShowHeader="True" Text="Remove" />
                    <asp:ButtonField ButtonType="Button" CommandName="Update"
                        HeaderText="PAYMENT" ShowHeader="true" Text="Pay $15 fee" />


                </Columns>
                <FooterStyle BackColor="#CCCC99" />
                <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                <RowStyle BackColor="#F7F7DE" />
                <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FBFBF2" />
                <SortedAscendingHeaderStyle BackColor="#848384" />
                <SortedDescendingCellStyle BackColor="#EAEAD3" />
                <SortedDescendingHeaderStyle BackColor="#575357" />
            </asp:GridView>  
        <hr>
        <h2>Make a Reservation</h2>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:UTD_HRRSConnectionString %>" 
                SelectCommand="SELECT DISTINCT [EQUIP_TYPE] FROM [INVENTORY]">
            </asp:SqlDataSource>

    <table class="controlcolumn" border="0" cellpadding="0" cellspacing="0" 
            frame="border">
        <tr>
            <td class="style1">
                Equipment/Room:</td>
            <td class="style2">
                <asp:DropDownList ID="DropDownList1" runat="server" 
                    DataSourceID="SqlDataSource3" DataTextField="EQUIP_TYPE" 
                    DataValueField="EQUIP_TYPE">
                </asp:DropDownList>
            </td>
            <td class="style4">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td class="style2">
                &nbsp;</td>
            <td class="style4">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style1">
                Start Date:</td>
            <td class="style2">
                <asp:Calendar ID="Calendar1" runat="server" Width="200px"></asp:Calendar>
            </td>
            <td class="style4">
                End Date:</td>
            <td class="style3" width="0">
                <asp:Calendar ID="Calendar2" runat="server" Width="200px"></asp:Calendar>
            </td>
        </tr>
        <tr>
            <td class="style1">
                Start Time:</td>
            <td class="style2">
                
                <asp:DropDownList id="ddList_sh" runat="Server">
  <asp:ListItem Text="0" />
  <asp:ListItem Text="1" />
  <asp:ListItem Text="2" />
  <asp:ListItem Text="3" />
  <asp:ListItem Text="4" />
  <asp:ListItem Text="5" />
  <asp:ListItem Text="6" />
  <asp:ListItem Text="7" />
  <asp:ListItem Text="8" Selected="True" />
  <asp:ListItem Text="9" />
  <asp:ListItem Text="10" />
  <asp:ListItem Text="11" />
  <asp:ListItem Text="12" />
  <asp:ListItem Text="13" />
  <asp:ListItem Text="14" />
  <asp:ListItem Text="15" />
  <asp:ListItem Text="16" />
  <asp:ListItem Text="17" />
  <asp:ListItem Text="18" />
  <asp:ListItem Text="19" />
  <asp:ListItem Text="20" />
  <asp:ListItem Text="21" />
  <asp:ListItem Text="22" />
  <asp:ListItem Text="23" />
</asp:DropDownList>
                HRS<br />
                
                <asp:DropDownList id="ddList_sm" runat="Server">
  <asp:ListItem Text="00" />
  <asp:ListItem Text="15" />
  <asp:ListItem Text="30" />
  <asp:ListItem Text="45" />

</asp:DropDownList>
                MIN</td>
            <td class="style4">
                End Time:</td>
            <td class="style3">
                
                <asp:DropDownList id="ddList_eh" runat="Server">
  <asp:ListItem Text="0" />
  <asp:ListItem Text="1" />
  <asp:ListItem Text="2" />
  <asp:ListItem Text="3" />
  <asp:ListItem Text="4" />
  <asp:ListItem Text="5" />
  <asp:ListItem Text="6" />
  <asp:ListItem Text="7" />
  <asp:ListItem Text="8" />
  <asp:ListItem Text="9" />
  <asp:ListItem Text="10" />
  <asp:ListItem Text="11" />
  <asp:ListItem Text="12" />
  <asp:ListItem Text="13" />
  <asp:ListItem Text="14" />
  <asp:ListItem Text="15" />
  <asp:ListItem Text="16" />
  <asp:ListItem Text="17" />
  <asp:ListItem Text="18" Selected="True" />
  <asp:ListItem Text="19" />
  <asp:ListItem Text="20" />
  <asp:ListItem Text="21" />
  <asp:ListItem Text="22" />
  <asp:ListItem Text="23" />
</asp:DropDownList>
                HRS<br />
                
                <asp:DropDownList id="ddList_em" runat="Server">
  <asp:ListItem Text="00" />
  <asp:ListItem Text="15" />
  <asp:ListItem Text="30" />
  <asp:ListItem Text="45" />

</asp:DropDownList>
                MIN</td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td class="style2">
            <asp:Label ID="myLabel" runat="server" Text="Label" Visible="False" ForeColor="Red"></asp:Label>
            </td>
            <td class="style4">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td class="style2">
                <asp:Button ID="Button2" runat="server" Text="Confirm Reservation" onclick="InsertTentativeReservation" />

            </td>
            <td class="style4">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
        </tr>
        </table>

    <br />
   
    </div>

    </form> 

</body>
</html>
